--#### SCENE KEYS ####--
-- w: moves luxor in the direction the head is facing
-- s: moves luxor in the revers direction that the head is facing
-- a: turns head left
-- d: turns head right
-- r: toggles "resting" position
-- t: toggles toon shading
-- +: increases toon border
-- -: decreases toon border
-- f: toggles lamp light on/off
-- v: toggles camera view

--#### Begin Settings ####--

	-- Quality
	sceneQuality		= 25
	
	-- Toon Shading Settings
	toonShading			= true
	toonBorderWidth		= 1
	toonBorderColor		= { 0, 0, 0, 1 }
	
	-- Animation settings
	domeRotationLimit	=  60	-- in (angle) degrees
	animationFrameTime	=  90	-- in milliseconds
	animationFrameSteps	=  10

--#### End Settings ####--


--#### BASIC SCENE PARAMETERS ####--
rootDir = "../data/"
luxorDir = rootDir .. "luxor/"

-- Build scene
scene = {}
scene.asset = {}
scene.environ = {}
scene.element = {}
scene.root = Scene()
scene.root:setName( "Luxor Scene" )
scene.root:setBackColor( 0.5, 0.5, 0.5, 1.0 )
scene.root:setBackfaceCulling( true )

-- Build camera and position
scene.camera = {}

scene.camera[0] = Camera()
scene.camera[0]:setName( "Camera 0" )
scene.camera[0]:translate( 0, 100, 300 )
scene.camera[0]:rotate( -20, 0, 0 )
scene.camera[0]:setZPlanes( 1, 5000 )
scene.camera[0]:setEye   ( 0, 0, 0.0001 )
scene.camera[0]:setCenter( 0, 0, 0 )
scene.camera[0]:setUp    ( 0, 1, 0 )

scene.camera[1] = Camera()
scene.camera[1]:setName( "Camera 1" )
scene.camera[1]:setZPlanes( 1, 5000 )
scene.camera[1]:setEye   ( 0, 0, -0.00001 )
scene.camera[1]:setCenter( 0, 0, 0 )
scene.camera[1]:setUp    ( 0, 1, 0 )
scene.camera[1]:translate( 0, 0, 4.7 )

-- Build manipulators
scene.asset["mouse_manipulator"] = MouseManipulator( scene.camera[0] )

-- Build light source
scene.light = {}

scene.light[0] = DirectionalLight()
scene.light[0]:setName( "Light 0" )
scene.light[0]:setAmbient ( 0.2, 0.2, 0.2, 1 )
scene.light[0]:setDiffuse ( 0.4, 0.4, 0.4, 1 )
scene.light[0]:setSpecular( 0.2, 0.2, 0.2, 1 )
scene.light[0]:setDirection( 0, 1, 0 )

scene.light[1] = SpotLight()
scene.light[1]:setName( "Light 1" )
scene.light[1]:setAmbient ( 1, 1, 1, 1 )
scene.light[1]:setDiffuse ( 1, 1, 1, 1 )
scene.light[1]:setSpecular( 1, 1, 1, 1 )
scene.light[1]:setCutoff  ( 60 )
scene.light[1]:setExponent( 10 )

-- Build environ
scene.environ[0] = Environ()
scene.environ[0]:setFogMode( 2 )
scene.environ[0]:setFogColor( 0.5, 0.5, 0.5, 1.0 )
scene.environ[0]:setFogDensity( 0.005 )
scene.environ[0]:setFogHint( 20 )
scene.environ[0]:setFogStart( 1000 )
scene.environ[0]:setFogEnd( 2000 )
scene.root:setEnviron( scene.environ[0] )



--#### SCENE ELEMENTS ####--
--# FLOOR #--
scene.asset["floorTexture"] = Texture( rootDir .. "wood.bmp" )
scene.asset["floorCube"] = Cube( 2500, 1, 2500 )
scene.asset["floorCube"]:setSegments( sceneQuality, sceneQuality, sceneQuality )
scene.element["floor"] = {}
scene.element["floor"].root = Transform()
scene.element["floor"].root:setName( "Floor (Root)" )
scene.element["floor"].entity = Entity( scene.asset["floorTexture"], scene.asset["floorCube"] )
scene.element["floor"].entity:setName( "Floor" )

--# BOXES #--
scene.asset["earthTexture"] = Texture( rootDir .. "earth.bmp" )
scene.asset["cube"] = Cube( 1, 1, 1 )
scene.element["boxes"] = {}
scene.element["boxes"].box = {}
scene.element["boxes"].box[0] = {}
scene.element["boxes"].box[0].root = Transform()
scene.element["boxes"].box[0].root:translate( -25, 20, -200 )
scene.element["boxes"].box[0].root:scale( 40, 40, 40 )
scene.element["boxes"].box[0].entity = Entity( scene.asset["earthTexture"], scene.asset["cube"] )
scene.element["boxes"].box[0].root:setName( "Box 0 (Root)" )
scene.element["boxes"].box[0].entity:setName( "Box 0" )

--# LUXOR LAMP #--
scene.asset["luxorBulbMat"] = Material()
scene.asset["luxorBulbMat"]:setAmbient  ( 0.8, 0.8, 0.2, 1 )
scene.asset["luxorBulbMat"]:setDiffuse  ( 0.8, 0.8, 0.8, 1 )
scene.asset["luxorBulbMat"]:setSpecular ( 0.2, 0.2, 0.2, 1 )
scene.asset["luxorBulbMat"]:setShininess( 50 )
scene.asset["luxorTexture"] = Texture( rootDir .. "plastic.bmp" )

scene.element["luxor"] = {}
scene.element["luxor"].root = Switch()
scene.element["luxor"].root:setName( "Luxor Root" )
scene.element["luxor"].frame = {}

-- Load all frames
dofile( luxorDir .. "luxorengine.lua" )
dofile( luxorDir .. "luxormodel.lua" )
dofile( luxorDir .. "frame0.lua" )
dofile( luxorDir .. "frame1.lua" )
dofile( luxorDir .. "frame2.lua" )
dofile( luxorDir .. "frame3.lua" )
dofile( luxorDir .. "frame4.lua" )

-- Set hierarchy
setHierarchy( scene )

-- Set initial keyframe (must be done after hierarchy is built)
changeFrame( 1 )

-- Print in console the scene keys
print( "" )
print( "### SCENE KEYS ####" )
print( "w: moves luxor in the direction the head is facing" )
print( "s: moves luxor in the revers direction that the head is facing" )
print( "a: turns head left" )
print( "d: turns head right" )
print( "r: toggles 'resting' position" )
print( "t: toggles toon shading" )
print( "+: increases toon border" )
print( "-: decreases toon border" )
print( "f: toggles lamp light on/off" )
print( "v: toggles camera view" )